javascript:(function (){

function trim (zeichenkette) {
  // Erst führende, dann Abschließende Whitespaces entfernen
  // und das Ergebnis dieser Operationen zurückliefern
  return zeichenkette.replace (/^\s+/, '').replace (/\s+$/, '');
}

function in_array(elem,arr) {
  var i;
  for (i = 0; i < arr.length; i++) {
    if (arr[i] == elem) {
      return true;
    }
  }
  return false;
}
function Item(id,name,skill,level){
    this.id=id;
    this.name = name;
	this.skill = skill;
	this.level = level;
}

function Property(id,name,items){
	 this.id=id;
	 this.name=name;
	 this.items=items;
}
var myProp = new Property();
function getParams(url){
  var ret = new Array();
  for(i=0;i<url.length;i++){
	var param_item = url[i].split("=");
	  ret[param_item[0]] = unescape(param_item[1]);
  }
  return ret;
}
var ItemList = new Array();

var out = '';
		$("div[id^='propsDiv']").each(
			function(i,e){				  				  				  
				  if (e.style.display == 'block'){
					  checkProperty(e);
					  return false;
				  }
				  
			}
			);  

function Skill(){
	this.att='';
	this.def='';
	this.energy='';
	this.stamina='';
	this.health='';
	
}
function checkProperty(prop){
	myProp.id = prop.id.replace("propsDiv","");
	myProp.name=$('#depotButton'+myProp.id).text();
	$(prop).find("div[class='recipe_card']").each(
		function (i,e){
		  var img = $(e).find("img[class='item_with_preview']")[0];
		  var itm_id= $(img).attr("item_id");
		  var itm_name = $(img).attr('alt').split(" [")[0];
		  var src = $(img).attr("src");
		  var lvl = 0;
		  if (src.indexOf('_bronze_') != -1){
			  lvl = 1;
		  }
		  if (src.indexOf('_silver_') != -1){
			  lvl = 2;
		  }		  
		  if (src.indexOf('_gold_') != -1){
			  lvl = 3;
		  }		  
		  if (src.indexOf('_ruby_') != -1){
			  lvl = 4;
		  }		  
		  if (src.indexOf('_emerald_') != -1){
			  lvl = 5;
		  }		  
		  var skill = new Skill();
		  if ($(e).find("span[class='attack']").length > 0){			  
			skill.att = parseInt($(e).find("span[class='attack']")[0].innerHTML.replace("+ ","")) ;
		  }		  
		  if ($(e).find("span[class='defense']").length > 0){
		    skill.def = parseInt($(e).find("span[class='defense']")[0].innerHTML.replace("+ ","")) ;
		  }		  
		  if ($(e).find("span[class='energy']").length > 0){
		    skill.energy = parseInt($(e).find("span[class='energy']")[0].innerHTML.replace("+ ","")) ;
		  }	
		  if ($(e).find("span[class='stamina']").length > 0){
		    skill.stamina = parseInt($(e).find("span[class='stamina']")[0].innerHTML.replace("+ ","")) ;
		  }			  
		  if ($(e).find("span[class='health']").length > 0){
		    skill.health = parseInt($(e).find("span[class='health']")[0].innerHTML.replace("+ ","")) ;
		  }	
		 ItemList.push(new Item(itm_id,itm_name,skill,lvl));
		  //console.info($(e).text());
		}
	);
	myProp.items = ItemList;
	//console.info(myProp);
}
function convert2demon(prop){
	var out = '';
	out +="{type:2,id:\""+prop.id+"\",a:\""+prop.name+"\",Oy: !0,\nT:[";
	for(var i=0;i<prop.items.length;i++){
		add = '';
		if (i<prop.items.length-1){
			add=',';
		}
		add_skill = '';
		if (prop.items[i].skill.att != ""){
			add_skill = ',A:'+prop.items[i].skill.att;
		}
		if (prop.items[i].skill.def != ""){
			add_skill = ',z:'+prop.items[i].skill.def;
		}		
		if (prop.items[i].skill.energy != ""){
			add_skill = ',u:'+prop.items[i].skill.energy;
		}		
		if (prop.items[i].skill.stamina != ""){
			add_skill = ',i:'+prop.items[i].skill.stamina;
		}	
		if (prop.items[i].skill.health != ""){
			add_skill = ',W:'+prop.items[i].skill.health;
		}	
		out +="{c:"+parseInt(prop.items[i].id)+",a:\""+prop.items[i].name+"\",d:"+parseInt(prop.items[i].level)+add_skill+"}"+add+"\n";
	}
	out+="]},";
	return out;
	
}
var the_div = document.getElementById('mw_masthead');
if (document.getElementById('text_logger') == undefined) {
		var the_count=document.createElement("div");
		the_count.id='limited_reader';		
		$(the_count).insertBefore(the_div);
		var the_close = document.createElement('a');
		the_close.id='limited_reader_close';
		the_close.innerHTML = '';
		the_close.className='close';
		the_close.href = '#';		
		var jca_out='<div id="limited_reader_areas">Human readable:<br><textarea id="limited_reader_content" cols="80" rows="10">';
		jca_out+=JSON.stringify(myProp);
	    jca_out+='</textarea>';
		jca_out+='<br>For demon:<br><textarea id="limited_reader_content_demon" cols="80" rows="10">';
		jca_out+=(convert2demon(myProp));
	    jca_out+='</textarea></div>';		
		the_count.innerHTML=jca_out;
		$(the_close).insertBefore(the_count);		
} else {
    document.getElementById('text_logger').value = '';
}	
	$(the_close).click(function(){$('#text_logger').remove();$('#limited_reader_areas').remove();$('#limited_reader').remove();$('#limited_reader_close').remove();});
	
return;
})();

